package calao.contact;

import calao.contact.client.Contact;
import calao.contact.client.PostAddress;
import calao.storage.Field;
import calao.storage.Sequence;
import calao.storage.ObjectTable;

public class ContactDB {

	public static final short PERSON = 1;
	public static final short ORGANIZATION = 2;
	
	static final ObjectTable<Contact> TABLE = 
		new ObjectTable<Contact>("calao.contact.Contact", new ContactBinding()); 

	static final Sequence ID_SEQUENCE = new Sequence("calao.contact.ContactId");
	
	public static final Field<Integer> ID = 
		TABLE.createField("id", Field.INTEGER);	

	public static final Field<Short> TYPE = 
		TABLE.createField("type", Field.SHORT);	

	public static final Field<String> NAME = 
		TABLE.createField("name", Field.STRING);	

	public static final Field<String> FIRST_NAME = 
		TABLE.createField("firstName", Field.STRING);	

	public static final Field<Integer> GROUP = 
		TABLE.createField("group", Field.INTEGER, true);	

	public static final Field<Integer> PERSON_ORGANIZATION = 
		TABLE.createField("personOrg", Field.INTEGER);	

	public static final Field<String> PHONE = 
		TABLE.createField("phone", Field.STRING);	

	public static final Field<String> FAX = 
		TABLE.createField("fax", Field.STRING);	

	public static final Field<String> EMAIL = 
		TABLE.createField("email", Field.STRING);	

	public static final Field<String> ORGANIZATION_COMPANY_NUMBER = 
		TABLE.createField("orgCompanyNumber", Field.STRING);	

	public static final Field<Double> ORGANIZATION_VAT_RATE = 
		TABLE.createField("orgVATRate", Field.DOUBLE);	

	public static final Field<String> ORGANIZATION_VAT_NUMBER = 
		TABLE.createField("orgVATNumber", Field.STRING);	
	
	public static final Field<PostAddress> POST_ADDRESS = 
		TABLE.createField("postAddress", PostAddress.class);		

	public static final Field<String> NOTES = 
		TABLE.createField("notes", Field.STRING);		

	static {
		TABLE.createPrimaryKeyIndex(ID);
		TABLE.createIndex(GROUP);
	}
	
}
